package com.huirui.server.controller.mini.program;

import com.huirui.server.pojo.result.Result;
import com.huirui.server.pojo.vo.HotSalesRankingProductVo;
import com.huirui.server.pojo.vo.HotSalesRankingVo;
import com.huirui.server.service.HotSalesRankingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("hotSalesRanking")
@RequestMapping("/api/ranking")
@Slf4j
@Validated
@Tag(name = "热销商品管理", description = "小程序热销商品管理")
public class HotSalesRankingController {

    @Resource
    private HotSalesRankingService hotSalesRankingService;

    @GetMapping("/list")
    @Operation(summary = "获取热销商品排行榜Item")
    public Result<List<HotSalesRankingVo>> listHotSalesRanking() {
        List<HotSalesRankingVo> list = hotSalesRankingService.listHotSalesRanking();
        return Result.success(list);
    }

    @GetMapping("/item/{id}")
    @Operation(summary = "根据分类ID获取热销排行榜")
    public Result<List<HotSalesRankingProductVo>> getHotSalesRanking(@PathVariable("id") Integer id) {
        List<HotSalesRankingProductVo> res = hotSalesRankingService.getHotSalesRankingProducts(id);
        return Result.success(res);
    }


}
